<?

// Obtengo las ultimas novedades
$novedades = $db->get_results("SELECT * FROM novedades WHERE 1=1 ORDER BY ctime DESC LIMIT 4");

$path = CONFIG_SITE_URL.'uploads/novedades/';

$current = 0;

?> 
			<h1 class="arrow-title">Novedades</h1>
		
			<div class="news-home">
			
				<div class="images" style="width: 490px; float: left;">
					<div id="slider">
						<?	foreach ($novedades as $k => $nov): ?>
						<img style="border: 1px #8aa6ce solid;" <?=($k == $current)? 'class="current"' : ''?> order="<?=$k?>" src="<?=$path.$nov['home_img']?>">
						<?	endforeach; ?>
					</div>
				</div>

				<div class="titles">
					<?	foreach ($novedades as $k => $nov): ?>
					<a href="/site/novedades/ver/<?=$nov['id_novedad']?>/<?=urlencode($nov['titulo'])?>/" class="<?=($k == $current)? 'selected' : ''?> <?=($k == count($novedades)-1)? 'last-child' : ''?>" order="<?=$k?>" ><span class="title"><?=$nov['titulo']?></span><p><?=$nov['home_texto']?></p></a>
					<?	endforeach; ?>
				</div>
			</div>

			<div class="pastillas">
				<?	foreach ($niveles as $k => $v): ?>
					<a href="/site/<?=$k?>/"><img src="/images/ui/home-<?=$k?>.png"></a>
				<?	endforeach; ?>
			</div>

<link rel="stylesheet" href="/css/nivo-slider.css" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" src="/js/jquery.nivo.slider.pack.js"></script>
<script type="text/javascript">

jQuery(window).load(function(){

    jQuery("#slider").nivoSlider({
        effect:"slideInRight",
        slices:15,
        boxCols:8,
        boxRows:4,
        animSpeed:500,
        pauseTime:3000,
        startSlide:0,
        directionNav:false,
        directionNavHide:false,
        controlNav:false,
        controlNavThumbs:false,
        controlNavThumbsFromRel:false,
        keyboardNav:false,
        pauseOnHover:false,
        manualAdvance:false,
        afterChange: function(){
			nextTitles();
		}
    });
});

	function nextTitles () {

		// Obtengo las imagenes
		var titles = $('.titles a');

		// Obtengo el titulo siguiente
		var current = $('.titles a.selected').attr('order');
		++current;
		var next = (current >= titles.length)? 0 : current;

		// Desactivo las actuales
		$('.titles a.selected').removeClass('selected');
		
		// Activo las nuevas
		$(titles[next]).addClass('selected');
	}


</script>
